package com.ocom.payconfig.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.card.EntityXfMerchantInfo;
import com.ocom.common.vo.pay.MachMerchPointInfoVo;
import com.ocom.common.vo.payconfig.FeeAccountRVo;
import com.ocom.common.vo.payconfig.FeeMerchRVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoXfMerchantInfo extends BaseMapper<EntityXfMerchantInfo> {


	@Select({"<script>",
			"select d.device_no as machNo,d.device_name as deviceName,d.status,\n" +
					"d.com_id as comId,p.point_id as pointId,p.point_name as pointName," +
					"m.merch_id as merchId,m.merch_name as merchName  \n" +
					"FROM xf_device_info d \n" +
					"LEFT JOIN xf_point_info p ON p.com_id=d.com_id AND p.point_id=d.point_id \n" +
					"LEFT JOIN xf_merchant_info m ON p.merch_id=m.merch_id and p.com_id=m.com_id \n " +
					"where d.com_id=#{comId} and d.device_no = #{machNo} ",
			"</script>"})
	MachMerchPointInfoVo getMerchPointInfo(@Param("comId")Long comId,@Param("machNo") String machNo);


	@Select("SELECT merch_id AS feeAccountId , merch_name AS feeAccountName , fee_flag AS `status` , remark \n" +
			"FROM `xf_merchant_info`  \n" +
			"WHERE com_id = #{comId} AND parent_merch_id = -8")
	List<FeeAccountRVo> getFeeAccount(@Param("comId")Long comId);

	@Select("SELECT m.merch_id AS feeMerchId , merch_name AS feeMerchName , fee_flag AS `status` , m.remark \n" +
			"FROM `xf_merchant_info` m LEFT JOIN xf_channel_info c ON m.merch_id = c.merch_id\n" +
			"WHERE m.com_id = #{comId} AND m.parent_merch_id >= -1\n" +
			"GROUP BY  feeMerchId")
	List<FeeMerchRVo> getFeeMerch(@Param("comId")Long comId);
}
